package ie.dit.reg08.realiser;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;


public class DescriptionWordCounts {

	private HashMap<String, AttributeWordCount> wordCounts;
	
	public DescriptionWordCounts(){
		wordCounts = new HashMap<String, AttributeWordCount>();
	}
	
	public boolean hasType(String type){
		return wordCounts.containsKey(type);
	}
	
	public void addType(String type){
		wordCounts.put(type, new AttributeWordCount(type));
	}
	
	public void addDescriptionText(String type, String val, String description){
		
		if(!wordCounts.containsKey(type)){
			addType(type);
		}
		
		wordCounts.get(type).incrementAttributeValuewordCounts(val, description);
	}
	
	public String toString(){
		
		StringBuffer s = new StringBuffer("");
	    
		
	    Set<String> ks = wordCounts.keySet();
		Iterator<String> iterKey = ks.iterator();
		String sKey;
		while(iterKey.hasNext()) {
			sKey = iterKey.next();
			s.append(wordCounts.get(sKey).toString() + "\n");
		}

	    return s.toString();
	}
}
